package com.wxl52d41.rocketmq;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @ClassName: ProducerService
 * @Description: 消息生产者service类
 * @Author wxl
 * @Date 2024-04-22
 * @Version 1.0.0
 **/
@Component("producerService")
public class ProducerService {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    /**
     * 发送简单消息
     */
    public void sendMessage(){
        for(int i=0;i<10;i++){
            rocketMQTemplate.convertAndSend("java1234-rocketmq","rocketmq大爷，你好"+i);
        }
    }
}
